<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />

  <title>Class: SQLConstructorTest</title>

  <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />

  <script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
  <script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
  <script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
  <script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>

</head>
<body id="top" class="class">

  <div id="metadata">
    <div id="home-metadata">
      <div id="home-section" class="section">
        <h3 class="section-header">
          <a href="./index.html">Home</a>
          <a href="./index.html#classes">Classes</a>
          <a href="./index.html#methods">Methods</a>
        </h3>
      </div>
    </div>

    <div id="file-metadata">
      <div id="file-list-section" class="section">
        <h3 class="section-header">In Files</h3>
        <div class="section-body">
          <ul>
          
            <li><a href="./test/queries_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
              class="thickbox" title="test/queries.rb">test/queries.rb</a></li>
          
          </ul>
        </div>
      </div>

      
    </div>

    <div id="class-metadata">
      
      <!-- Parent Class -->
      <div id="parent-class-section" class="section">
        <h3 class="section-header">Parent</h3>
        
        <p class="link">Test::Unit::TestCase</p>
        
      </div>
      

      

      

      
      <!-- Method Quickref -->
      <div id="method-list-section" class="section">
        <h3 class="section-header">Methods</h3>
        <ul class="link-list">
          
          <li><a href="#method-i-delete1">#delete1</a></li>
          
          <li><a href="#method-i-insert1">#insert1</a></li>
          
          <li><a href="#method-i-select1">#select1</a></li>
          
          <li><a href="#method-i-select2">#select2</a></li>
          
          <li><a href="#method-i-test_delete1">#test_delete1</a></li>
          
          <li><a href="#method-i-test_insert1">#test_insert1</a></li>
          
          <li><a href="#method-i-test_select1">#test_select1</a></li>
          
          <li><a href="#method-i-test_select2">#test_select2</a></li>
          
          <li><a href="#method-i-test_update1">#test_update1</a></li>
          
          <li><a href="#method-i-update1">#update1</a></li>
          
        </ul>
      </div>
      

      
    </div>

    <div id="project-metadata">
      
      
      <div id="fileindex-section" class="section project-section">
        <h3 class="section-header">Files</h3>
        <ul>
        
          <li class="file"><a href="./Rakefile.html">Rakefile</a></li>
        
        </ul>
      </div>
      

      <div id="classindex-section" class="section project-section">
        <h3 class="section-header">Class/Module Index
          <span class="search-toggle"><img src="./images/find.png"
            height="16" width="16" alt="[+]"
            title="show/hide quicksearch" /></span></h3>
        <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
        <fieldset>
          <legend>Quicksearch</legend>
          <input type="text" name="quicksearch" value=""
            class="quicksearch-field" />
        </fieldset>
        </form>

        <ul class="link-list">
        
          <li><a href="./SQLConstructor.html">SQLConstructor</a></li>
        
          <li><a href="./SQLConstructor/BasicDelete.html">SQLConstructor::BasicDelete</a></li>
        
          <li><a href="./SQLConstructor/BasicDelete_mysql.html">SQLConstructor::BasicDelete_mysql</a></li>
        
          <li><a href="./SQLConstructor/BasicInsert.html">SQLConstructor::BasicInsert</a></li>
        
          <li><a href="./SQLConstructor/BasicInsert_mysql.html">SQLConstructor::BasicInsert_mysql</a></li>
        
          <li><a href="./SQLConstructor/BasicJoin.html">SQLConstructor::BasicJoin</a></li>
        
          <li><a href="./SQLConstructor/BasicJoin_mysql.html">SQLConstructor::BasicJoin_mysql</a></li>
        
          <li><a href="./SQLConstructor/BasicSelect.html">SQLConstructor::BasicSelect</a></li>
        
          <li><a href="./SQLConstructor/BasicSelect_example.html">SQLConstructor::BasicSelect_example</a></li>
        
          <li><a href="./SQLConstructor/BasicSelect_mysql.html">SQLConstructor::BasicSelect_mysql</a></li>
        
          <li><a href="./SQLConstructor/BasicUnion.html">SQLConstructor::BasicUnion</a></li>
        
          <li><a href="./SQLConstructor/BasicUpdate.html">SQLConstructor::BasicUpdate</a></li>
        
          <li><a href="./SQLConstructor/BasicUpdate_mysql.html">SQLConstructor::BasicUpdate_mysql</a></li>
        
          <li><a href="./SQLConstructor/GenericQuery.html">SQLConstructor::GenericQuery</a></li>
        
          <li><a href="./SQLConstructor/QAttr.html">SQLConstructor::QAttr</a></li>
        
          <li><a href="./SQLExporter.html">SQLExporter</a></li>
        
          <li><a href="./SQLExporter/Exporter_generic.html">SQLExporter::Exporter_generic</a></li>
        
          <li><a href="./SQLExporter/Exporter_mysql.html">SQLExporter::Exporter_mysql</a></li>
        
          <li><a href="./SQLConditional.html">SQLConditional</a></li>
        
          <li><a href="./SQLConditional/BasicCond.html">SQLConditional::BasicCond</a></li>
        
          <li><a href="./Object.html">Object</a></li>
        
          <li><a href="./SQLAliasedList.html">SQLAliasedList</a></li>
        
          <li><a href="./SQLColumn.html">SQLColumn</a></li>
        
          <li><a href="./SQLCondList.html">SQLCondList</a></li>
        
          <li><a href="./SQLConstructorTest.html">SQLConstructorTest</a></li>
        
          <li><a href="./SQLObject.html">SQLObject</a></li>
        
          <li><a href="./SQLValList.html">SQLValList</a></li>
        
          <li><a href="./SQLValue.html">SQLValue</a></li>
        
        </ul>
        <div id="no-class-search-results" style="display: none;">No matching classes.</div>
      </div>

      
    </div>
  </div>

  <div id="documentation">
    <h1 class="class">SQLConstructorTest</h1>

    <div id="description" class="description">
      
    </div><!-- description -->

    
    
    
    <div id="5Buntitled-5D" class="documentation-section">
      

      

      

      

      <!-- Methods -->
      
      <div id="public-instance-method-details" class="method-section section">
        <h3 class="section-header">Public Instance Methods</h3>

      
        <div id="delete1-method" class="method-detail ">
          <a name="method-i-delete1"></a>

          
          <div class="method-heading">
            <span class="method-name">delete1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="delete1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete1</span>
    <span class="ruby-identifier">sql</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> )
    <span class="ruby-identifier">inner_sel3</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> ).<span class="ruby-identifier">select</span>( <span class="ruby-value">:keyword_id</span> ).<span class="ruby-identifier">distinct</span>.<span class="ruby-identifier">from</span>( <span class="ruby-value">:customer_analysis</span> )
    <span class="ruby-identifier">inner_sel2</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> ).<span class="ruby-identifier">select</span>( <span class="ruby-value">:&quot;k.keyword&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:id</span> ).<span class="ruby-identifier">from</span>( <span class="ruby-value">:keywords</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:k</span> ).
                 <span class="ruby-identifier">where</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;k.keyword_type&quot;</span>, <span class="ruby-string">&quot;CAMPAIGN&quot;</span> ).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">ne</span>( <span class="ruby-value">:&quot;k.keyword&quot;</span>, <span class="ruby-string">&quot;Airtel&quot;</span> ).
                 <span class="ruby-identifier">and</span>.<span class="ruby-identifier">ne</span>( <span class="ruby-value">:&quot;k.keyword&quot;</span>, <span class="ruby-string">&quot;Nokia&quot;</span> ).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">ne</span>( <span class="ruby-value">:&quot;k.keyword&quot;</span>, <span class="ruby-string">&quot;Micromax&quot;</span> ).
                 <span class="ruby-identifier">and</span>.<span class="ruby-identifier">not_in</span>( <span class="ruby-value">:&quot;k.keyword&quot;</span>, <span class="ruby-identifier">inner_sel3</span> ).<span class="ruby-identifier">order_by</span>( <span class="ruby-value">:&quot;k.keyword_id&quot;</span> )
    <span class="ruby-identifier">inner_sel1</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> ).<span class="ruby-identifier">select</span>( <span class="ruby-value">:id</span> ).<span class="ruby-identifier">from</span>( <span class="ruby-identifier">inner_sel2</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:a</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">delete</span>.<span class="ruby-identifier">from</span>( <span class="ruby-value">:keywords</span> ).<span class="ruby-identifier">where</span>.<span class="ruby-identifier">in</span>( <span class="ruby-value">:keyword_id</span>, <span class="ruby-identifier">inner_sel1</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- delete1-source -->
            
          </div>

          

          
        </div><!-- delete1-method -->

      
        <div id="insert1-method" class="method-detail ">
          <a name="method-i-insert1"></a>

          
          <div class="method-heading">
            <span class="method-name">insert1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="insert1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">insert1</span>
    <span class="ruby-identifier">sql</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">insert</span>.<span class="ruby-identifier">into</span>(<span class="ruby-value">:table2</span>).<span class="ruby-identifier">select</span>(<span class="ruby-value">:name</span>, <span class="ruby-value">:&quot;CONCAT('blah=',ID)&quot;</span>).<span class="ruby-identifier">from</span>(<span class="ruby-value">:table1</span>)
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- insert1-source -->
            
          </div>

          

          
        </div><!-- insert1-method -->

      
        <div id="select1-method" class="method-detail ">
          <a name="method-i-select1"></a>

          
          <div class="method-heading">
            <span class="method-name">select1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="select1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">select1</span>
    <span class="ruby-identifier">sql</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">select</span>(<span class="ruby-value">:col1</span>,<span class="ruby-value">:col2</span>).<span class="ruby-identifier">from</span>(<span class="ruby-value">:table1</span>).<span class="ruby-identifier">where</span>.<span class="ruby-identifier">eq</span>(<span class="ruby-value">:col1</span>, <span class="ruby-value">123</span>).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">in</span>(<span class="ruby-value">:col2</span>,[<span class="ruby-string">&quot;value1&quot;</span>,<span class="ruby-string">&quot;value2&quot;</span>,<span class="ruby-node">&quot;@#\$%^&quot;</span>])
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">limit</span>( <span class="ruby-value">100</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">union</span>.<span class="ruby-identifier">_name</span>(<span class="ruby-string">&quot;u1&quot;</span>).<span class="ruby-identifier">select</span>(<span class="ruby-value">:baz</span>).<span class="ruby-identifier">from</span>(<span class="ruby-value">:table2</span>)
    <span class="ruby-identifier">c2</span> = <span class="ruby-constant">SQLConditional</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">eq</span>(<span class="ruby-value">:c1</span>,<span class="ruby-value">3</span>).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">in</span>(<span class="ruby-value">:c2</span>,[<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value">3</span>,<span class="ruby-value">4</span>,<span class="ruby-value">5</span>]).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">eq</span>(<span class="ruby-value">:s1</span>,<span class="ruby-string">'somestring'</span>)
    <span class="ruby-identifier">c1</span> = <span class="ruby-constant">SQLConditional</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">eq</span>(<span class="ruby-value">:c1</span>,<span class="ruby-value">5</span>).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">lt</span>(<span class="ruby-value">:c2</span>,<span class="ruby-value">6</span>).<span class="ruby-identifier">or</span>.<span class="ruby-identifier">is</span>(<span class="ruby-identifier">c2</span>)
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">where</span>.<span class="ruby-identifier">and</span>.<span class="ruby-identifier">is</span>(<span class="ruby-identifier">c1</span>)
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value">:table3</span> ).<span class="ruby-identifier">_name</span>(<span class="ruby-string">'j1'</span>).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:col1</span>, <span class="ruby-value">:ccc1</span> ).<span class="ruby-identifier">use_index</span>( <span class="ruby-value">:col1</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value">:table4</span>,<span class="ruby-value">:table5</span> ).<span class="ruby-identifier">_name</span>(<span class="ruby-string">'j2'</span>).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:col2</span>, <span class="ruby-value">:ccc2</span>).<span class="ruby-identifier">and</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:col3</span>, <span class="ruby-value">5</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">union</span>.<span class="ruby-identifier">_name</span>(<span class="ruby-string">&quot;u2&quot;</span>).<span class="ruby-identifier">select</span>(<span class="ruby-value">:fooz</span>).<span class="ruby-identifier">from</span>(<span class="ruby-value">:table5</span>).<span class="ruby-identifier">limit</span>( <span class="ruby-value">20</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- select1-source -->
            
          </div>

          

          
        </div><!-- select1-method -->

      
        <div id="select2-method" class="method-detail ">
          <a name="method-i-select2"></a>

          
          <div class="method-heading">
            <span class="method-name">select2</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="select2-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 45</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">select2</span>
    <span class="ruby-identifier">sql</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">select</span>( <span class="ruby-value">:&quot;t.id&quot;</span>,<span class="ruby-value">:&quot;t.tag&quot;</span>,<span class="ruby-value">:&quot;c.title&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:category</span> ).<span class="ruby-identifier">from</span>( <span class="ruby-value">:tags2Articles</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:t2a</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">inner_join</span>( <span class="ruby-value">:tags</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:t</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>(<span class="ruby-value">:&quot;t.id&quot;</span>, <span class="ruby-value">:&quot;t2a.idTag&quot;</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">inner_join</span>( <span class="ruby-value">:categories</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:c</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;t.tagCategory&quot;</span>, <span class="ruby-value">:&quot;c.id&quot;</span> )
    <span class="ruby-identifier">inner_sql</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> )
    <span class="ruby-identifier">inner_sql</span>.<span class="ruby-identifier">select</span>( <span class="ruby-value">:&quot;a.id&quot;</span> ).<span class="ruby-identifier">from</span>( <span class="ruby-value">:articles</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:a</span> )
    <span class="ruby-identifier">inner_sql</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value">:tags2articles</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:ta</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;a.id&quot;</span>, <span class="ruby-value">:&quot;ta.idArticle&quot;</span> )
    <span class="ruby-identifier">inner_sql</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value">:tags</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:tsub</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;ta.idTag&quot;</span>, <span class="ruby-value">:&quot;tsub.id&quot;</span> )
    <span class="ruby-identifier">inner_sql</span>.<span class="ruby-identifier">where</span>.<span class="ruby-identifier">in</span>( <span class="ruby-value">:&quot;tsub.id&quot;</span>, [<span class="ruby-value">12</span>,<span class="ruby-value">13</span>,<span class="ruby-value">16</span>] ).<span class="ruby-identifier">group_by</span>( <span class="ruby-value">:&quot;a.id&quot;</span> ).
              <span class="ruby-identifier">having</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;COUNT(DISTINCT tsub.id)&quot;</span>, <span class="ruby-value">3</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">inner_join</span>( <span class="ruby-identifier">inner_sql</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'asub'</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;t2a.idArticle&quot;</span>, <span class="ruby-value">:&quot;asub.id&quot;</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- select2-source -->
            
          </div>

          

          
        </div><!-- select2-method -->

      
        <div id="test_delete1-method" class="method-detail ">
          <a name="method-i-test_delete1"></a>

          
          <div class="method-heading">
            <span class="method-name">test_delete1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="test_delete1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 21</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_delete1</span>
    <span class="ruby-identifier">assert_equal</span> <span class="ruby-string">&quot;DELETE\nFROM keywords\nWHERE \n(keyword_id IN \n(SELECT\n id\nFROM \n(SELECT\n k.keyword id\nFROM keywords k\nWHERE \n(k.keyword_type = 'CAMPAIGN'  AND k.keyword != 'Airtel'  AND k.keyword != 'Nokia'  AND k.keyword != 'Micromax'  AND k.keyword NOT IN \n(SELECT\nDISTINCT\n keyword_id\nFROM customer_analysis\n))\nORDER BY k.keyword_id\n) a\n))\n&quot;</span>,
                 <span class="ruby-identifier">delete1</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- test_delete1-source -->
            
          </div>

          

          
        </div><!-- test_delete1-method -->

      
        <div id="test_insert1-method" class="method-detail ">
          <a name="method-i-test_insert1"></a>

          
          <div class="method-heading">
            <span class="method-name">test_insert1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="test_insert1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 16</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_insert1</span>
    <span class="ruby-identifier">assert_equal</span> <span class="ruby-string">&quot;INSERT\nINTO table2\n SELECT\n name,CONCAT('blah=',ID)\nFROM table1\n\n&quot;</span>,
                 <span class="ruby-identifier">insert1</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- test_insert1-source -->
            
          </div>

          

          
        </div><!-- test_insert1-method -->

      
        <div id="test_select1-method" class="method-detail ">
          <a name="method-i-test_select1"></a>

          
          <div class="method-heading">
            <span class="method-name">test_select1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="test_select1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 6</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_select1</span>
    <span class="ruby-identifier">assert_equal</span> <span class="ruby-string">&quot;SELECT\n col1,col2\nFROM table1\nJOIN table3 USE INDEX (col1)\nON \n(col1 = ccc1)\nJOIN table4,table5\nON \n(col2 = ccc2  AND col3 = 5)\nWHERE \n(col1 = 123  AND col2 IN ('value1','value2','@\#$%^')  AND \n(c1 = 5  AND c2 &lt; 6  OR  (c1 = 3  AND c2 IN (1,2,3,4,5)  AND s1 = 'somestring')))\nLIMIT 100\nUNION\nSELECT\n baz\nFROM table2\nUNION\nSELECT\n fooz\nFROM table5\nLIMIT 20\n\n&quot;</span>, 
                 <span class="ruby-identifier">select1</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- test_select1-source -->
            
          </div>

          

          
        </div><!-- test_select1-method -->

      
        <div id="test_select2-method" class="method-detail ">
          <a name="method-i-test_select2"></a>

          
          <div class="method-heading">
            <span class="method-name">test_select2</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="test_select2-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 11</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_select2</span>
    <span class="ruby-identifier">assert_equal</span> <span class="ruby-string">&quot;SELECT\n t.id,t.tag,c.title category\nFROM tags2Articles t2a\nINNER JOIN tags t\nON \n(t.id = t2a.idTag)\nINNER JOIN categories c\nON \n(t.tagCategory = c.id)\nINNER JOIN \n(SELECT\n a.id\nFROM articles a\nJOIN tags2articles ta\nON \n(a.id = ta.idArticle)\nJOIN tags tsub\nON \n(ta.idTag = tsub.id)\nWHERE \n(tsub.id IN (12,13,16))\nGROUP BY a.id\nHAVING \n(COUNT(DISTINCT tsub.id) = 3)\n) asub\nON \n(t2a.idArticle = asub.id)\n&quot;</span>,
                 <span class="ruby-identifier">select2</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- test_select2-source -->
            
          </div>

          

          
        </div><!-- test_select2-method -->

      
        <div id="test_update1-method" class="method-detail ">
          <a name="method-i-test_update1"></a>

          
          <div class="method-heading">
            <span class="method-name">test_update1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="test_update1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 26</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_update1</span>
    <span class="ruby-identifier">assert_equal</span> <span class="ruby-string">&quot;UPDATE\n guest g\nSET link_id=\n(SELECT\n MAX(h.host_id)\nFROM guest_data d\nINNER JOIN host_data h\nON \n(d.guest_nm = hhost_nm)\nWHERE \n(d.guest_id = g.guest_id)\nGROUP BY h.venue_nm\nHAVING \n(COUNT(*) = 1)\n)\nWHERE \n(g.guest_id IN \n(SELECT\n d.guest_id\nFROM guest_data d\nINNER JOIN host_data h\nON \n(d.guest_nm = hhost_nm)\nGROUP BY h.venue_nm\nHAVING \n(COUNT(*) = 1)\n))\n&quot;</span>,
                 <span class="ruby-identifier">update1</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- test_update1-source -->
            
          </div>

          

          
        </div><!-- test_update1-method -->

      
        <div id="update1-method" class="method-detail ">
          <a name="method-i-update1"></a>

          
          <div class="method-heading">
            <span class="method-name">update1</span><span
              class="method-args">()</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="update1-source">
<pre>
<span class="ruby-comment"># File test/queries.rb, line 78</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update1</span>
    <span class="ruby-identifier">sql</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span> )
    <span class="ruby-identifier">in_sel1</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span> )
    <span class="ruby-identifier">in_sel1</span>.<span class="ruby-identifier">select</span>( <span class="ruby-value">:&quot;MAX(h.host_id)&quot;</span> ).<span class="ruby-identifier">from</span>( <span class="ruby-value">:guest_data</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:d</span> ).
              <span class="ruby-identifier">inner_join</span>( <span class="ruby-value">:host_data</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:h</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;d.guest_nm&quot;</span>, <span class="ruby-value">:hhost_nm</span> ).<span class="ruby-identifier">where</span>. 
              <span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;d.guest_id&quot;</span>, <span class="ruby-value">:&quot;g.guest_id&quot;</span> ).<span class="ruby-identifier">group_by</span>( <span class="ruby-value">:&quot;h.venue_nm&quot;</span> ).<span class="ruby-identifier">having</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;COUNT(*)&quot;</span>, <span class="ruby-value">1</span> )
    <span class="ruby-identifier">in_sel2</span> = <span class="ruby-constant">SQLConstructor</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:dialect</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'mysql'</span>, <span class="ruby-value">:tidy</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span> )
    <span class="ruby-identifier">in_sel2</span>.<span class="ruby-identifier">select</span>( <span class="ruby-value">:&quot;d.guest_id&quot;</span> ).<span class="ruby-identifier">from</span>( <span class="ruby-value">:guest_data</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:d</span> ).
              <span class="ruby-identifier">inner_join</span>( <span class="ruby-value">:host_data</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:h</span> ).<span class="ruby-identifier">on</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;d.guest_nm&quot;</span>, <span class="ruby-value">:hhost_nm</span> ).
              <span class="ruby-identifier">group_by</span>( <span class="ruby-value">:&quot;h.venue_nm&quot;</span> ).<span class="ruby-identifier">having</span>.<span class="ruby-identifier">eq</span>( <span class="ruby-value">:&quot;COUNT(*)&quot;</span>, <span class="ruby-value">1</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">update</span>( <span class="ruby-value">:guest</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:g</span> ).<span class="ruby-identifier">set</span>( <span class="ruby-value">:link_id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">in_sel1</span>).<span class="ruby-identifier">where</span>.<span class="ruby-identifier">in</span>( <span class="ruby-value">:&quot;g.guest_id&quot;</span>, <span class="ruby-identifier">in_sel2</span> )
    <span class="ruby-identifier">sql</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- update1-source -->
            
          </div>

          

          
        </div><!-- update1-method -->

      
      </div><!-- public-instance-method-details -->
    
    </div><!-- 5Buntitled-5D -->
  

  </div><!-- documentation -->

  <div id="validator-badges">
    <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
    <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
      Rdoc Generator</a> 2</small>.</p>
  </div>

</body>
</html>

